package com.example.mapping.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.example.mapping.common.core.ResultResponse;
import com.example.mapping.domain.Dict;
import com.example.mapping.dto.DictDto;
import com.example.mapping.dto.DictQueryDto;
import com.example.mapping.dto.FlowModelDto;
import com.example.mapping.dto.RuleQueryDto;
import com.example.mapping.manage.DictManage;
import com.example.mapping.manage.FlowModelManage;
import com.example.mapping.sevice.DictService;
import com.example.mapping.vo.DictVo;
import com.example.mapping.vo.FlowModelVo;
import com.example.mapping.vo.RuleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 字典controller类
 * @author baoyoujia
 */
@RestController
@RequestMapping("/dict")
public class DictController {
    @Autowired
    private DictManage dictManage;

    @GetMapping("/dict")
    public ResultResponse<PageDTO<DictVo>> getRuleListByPage(DictQueryDto ruleQueryDto) {
        return ResultResponse.buildSuccess(dictManage.getDictByPage(ruleQueryDto));
    }

    @GetMapping("/{id}")
    public ResultResponse<DictVo> get(@PathVariable("id") Long id) {
        return ResultResponse.buildSuccess(dictManage.getDict(id));
    }

    @PostMapping("/dict")
    public ResultResponse<Boolean> add(@RequestBody DictDto dictDto) {
        return ResultResponse.buildSuccess(dictManage.addDict(dictDto));
    }

    @PutMapping("/{id}")
    public ResultResponse<Boolean> edit(@PathVariable("id") Long id, @RequestBody DictDto dictDto) {
        dictDto.setId(id);
        return ResultResponse.buildSuccess(dictManage.editDict(dictDto));
    }

    @DeleteMapping("/{id}")
    public ResultResponse<Boolean> del(@PathVariable("id") Long id) {
        return ResultResponse.buildSuccess(dictManage.delDict(id));
    }

}
